
module.exports = app => {

    return class HomeController extends app.Controller {

        async list() {
            let guardian = await this.service.guardian.list();
            await this.ctx.render('member/guardian/index.js', {
                guardian
            });
        }

        async info() {
            let id = this.ctx.request.query;
            let guardian = await this.service.guardian.getGuardian({ id });
            await this.ctx.render('member/guardian/info/index.js', {
                guardian
            });
        }

        async edit() {
            let id = this.ctx.request.query;
            let guardian = await this.service.guardian.list({ id });
            await this.ctx.render('member/guardian/edit/index.js', {
                guardian
            });
        }

        async add() {
            await this.ctx.render('member/guardian/add/index.js');
        }


        async delete() {
            let id = this.ctx.request.body.id;
            await this.service.guardian.delete({
                id
            });
            this.success();
        }

        async editGuardian() {
            let params = this.ctx.request.body;
            await this.service.guardian.edit(params);
            this.success();
        }

    };
};
